/**
 * @description Order Model
 */
const mongoose = require('../db/db')
const Schema = mongoose.Schema({
  username: {
    type: String,
    require: true
  },
  address: {
    city: String,
    department: String,
    houseNumber: String,
    name: String,
    phone: String
  },
  shopId: String, // 商店 id
  shopName: String,

  // 订单是否被取消
  isCanceled: {
      type: Boolean,
      default: false // 默认不取消
  }, 
  products: [
    {
      orderSales: Number, // 销量
      product: {
        shopId: { // 商店 id
          type: String,
          require: true
        },
        name: String,
        imgUrl: String,
        sales: Number, // 月售多少
        price: Number, // 当前价格
        oldPrice: Number, // 原价
        tabs:[String]
      }
    }
  ]
}, { timestamps: true })
const Order=mongoose.model('order',Schema)
module.exports=Order